window.onload = initButton;

function initButton() {
	if (document.getElementById) {// 对象检测
		document.getElementById("button1").onclick = showButtonInfo;
		document.getElementById("button2").onclick = showButtonInfo;
		document.getElementById("button3").onclick = showButtonInfo;
	}
}

function showButtonInfo() {
	switch (this.id) {
	case "button1": // 此处为冒号
		alert("Click on " + this.value);
		break;
	case "button2":
		alert("Click on " + this.value);
		break;
	case "button3":
		alert("Click on " + this.value);
		break;
	default:
	}

}